﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Mtool.FSM;

namespace MToolStudio
{
    public partial class ModifyVariable : Form
    {
        public ModifyVariable()
        {
            InitializeComponent();
        }

        public ModifyVariable(PictInputVariable v)
            : base()
        {
            Variable = v;
        }

        private PictInputVariable var;

        public PictInputVariable Variable
        {
            get
            { 
                return var; 
            }
            set
            {
                var = value;
                if (var != null)
                {
                    textBox_varDims.Text = var.Order.ToString();
                    textBox_varName.Text = var.Name;
                    textBox_varValues.Text = var.ValuesString;
                }

            }
        }

        private void button_varSave_Click(object sender, EventArgs e)
        {
            try
            {
                var.Order = Convert.ToInt32(textBox_varDims.Text);
                var.ValuesString = textBox_varValues.Text;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Save failed: " + ex.ToString());
            }
            Close();
        }
    }
}
